﻿using System;
using System.Data;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Linq;
using Models;


public partial class Admin_shop_SendGoods : AdminBase
{
    public int _Id = 0;
    protected void Page_Load(object sender, EventArgs e)
    {
        Response.CacheControl = "no-cache";
        if (!string.IsNullOrEmpty(Request.Params["ID"]))
        {
            _Id = int.Parse(HttpContext.Current.Request.QueryString["ID"]);
        }
        if (!Page.IsPostBack)
        {
            Entities mydb = new Entities();
            {

                S_Order Lfb = mydb.S_Order.SingleOrDefault(p => p.OrderID == _Id);
                LabUser.Text = Lfb.OPeople + "&nbsp;&nbsp;/" + Lfb.Otel;
              LabAddress.Text = Lfb.OProvance+ Lfb.OCity +  Lfb.ODistrict+"&nbsp;" + Lfb.OAddress;
                RadioButtonList1.SelectedValue= Lfb.OState.ToString();
                if(!string.IsNullOrEmpty(Lfb.OPostway))
                txtCode.Text = Lfb.OPostway.ToString();
                ddrCompany.SelectedValue = Lfb.OPostCode.ToString();
            }
        }
    }

    //保存
    protected void btnSave_Click(object sender, EventArgs e)
    {
        Entities mydb = new Entities();
        {
        
           var Lfb = mydb.S_Order.FirstOrDefault(p => p.OrderID == _Id);
            Lfb.OPostway = this.txtCode.Text.Trim();
            Lfb.OPostCode = int.Parse(ddrCompany.SelectedItem.Value); 
            Lfb.OState = int.Parse(RadioButtonList1.SelectedValue);

            //mydb.S_Order.Add(Lfb);
            mydb.SaveChanges();
            Response.Write("<script> var success=1;</script>");
        }
    }
}

